package org.subside.MQ.rabbitmq.config;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;

public class ConnectionUtil {
    public static Connection getConnection() throws Exception {
        //定义连接工厂
        ConnectionFactory factory = new ConnectionFactory();
        //设置服务地址 "192.168.146.251",5672,"/","guest","guest"
        factory.setHost("192.168.80.144");
        //端口
        factory.setPort(5672);
        //设置账号信息，用户名、密码、vhost
        factory.setVirtualHost("TestHost");
        factory.setUsername("admin");
        factory.setPassword("zhangbo");
        // 通过工程获取连接
        return factory.newConnection();
    }
}
